# Maintainer: David Runge <dvzrv@archlinux.org>

_name=lazr.config
pkgname=python-lazr.config
pkgver=3.0
pkgrel=2
pkgdesc="Create configuration schemas, and process and validate configurations"
arch=(any)
url="https://launchpad.net/lazr.config"
license=(LGPL3)
depends=(
  python
  python-lazr.delegates
  python-setuptools
  python-zope-interface
)
makedepends=(
  python-build
  python-installer
  python-wheel
)
checkdepends=(
  python-zope-testrunner
)
provides=(python-lazr-config)
replaces=(python-lazr-config)
source=(https://files.pythonhosted.org/packages/source/${_name::1}/$_name/$_name-$pkgver.tar.gz{,.asc})
sha512sums=('15f61ca9e53e0677e228365318b99c1a65f674bf82dc1f8210335f93f4c74da2e9b09d8f8650506a133db85c45bfba12ff28ad3bc7c56edcf8c6e19c152f13f9'
            'SKIP')
b2sums=('538ab2e5f45c062dce8a53554eb646909940b41f8f5ae74038771a0cbb35b93878672b06bf967ecfc23232278aa86521def56dd1dfcab32668adb1fb73a72eee'
        'SKIP')
validpgpkeys=(
  AC0A4FF12611B6FCCF01C111393587D97D86500B  # Colin Watson <cjwatson@chiark.greenend.org.uk>
  760D8F2C93E9CA8562E4A00E75D673C2DD1FB761  # Jürgen Gmach <juergen.gmach@canonical.com>
)

build() {
  cd $_name-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd $_name-$pkgver
  python -m installer --destdir=test_dir dist/*.whl
  export PYTHONPATH="$PWD/test_dir/$site_packages:$PYTHONPATH"
  python -m zope.testrunner --test-path src --tests-pattern ^tests
}

package() {
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 {NEWS,README}.rst -t "$pkgdir/usr/share/doc/$pkgname/"
  rm -frv "$pkgdir/$site_packages/lazr/config/tests"
}
